
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from functools import partial

import os
import sys
sys.path.append(os.getcwd())
# from Sequence.main import Main
# import Sequence.main as Main


class ThemeSelect(ttk.Frame):
    
    themeArray = ["Production","Audit"]
    _select_listen = None
    cbo = None
    
    def __init__(self, master,select_listen=None):
        super().__init__(master,width=4)
        self.pack()
        self.data = self.themeArray
        self.create_ui()
    # 事件回调
        if select_listen:
            if callable(select_listen):
                self._select_listen = select_listen
            else:
                raise Exception("select_action is not callable")

    def btnAction(self,event):
        print(self.cbo.get())
        if self._select_listen:
                self._select_listen(self.cbo.get())

         
    def create_ui(self):
        self.cbo = ttk.Combobox(
            master=self,
            values=self.themeArray
            # command=partial(self.btnAction(cbo)),
        )
        # cbo.config(COMMAND=partial(self.btnAction(cbo)))
        self.cbo.current(0)
        self.cbo.pack(fill=X, padx=(5, 5), pady=5)
        self.cbo.bind("<<ComboboxSelected>>",self.btnAction)
        

if __name__ == "__main__":
    app = ttk.Window(
        title = "Demo",
        themename="cosmo",
    )
    ThemeSelect(app)
    app.mainloop()
